<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <title>KindEditor</title>
    <style type="text/css">
    html{padding:0;margin:0;}
    body{padding:0;margin:0;}
    </style>
</head>
<body>
<div style="width:800px;margin:30px auto 0 auto;">
    <textarea name="content" style="width:100%;height:700px;visibility:hidden;"></textarea>
    <p>
        <input type="button" name="getHtml" value="取得HTML" />
        <input type="button" name="isEmpty" value="判断是否为空" />
        <input type="button" name="getText" value="取得文本(包含img,embed)" />
        <input type="button" name="selectedHtml" value="取得选中HTML" />
        <br />
        <br />
        <input type="button" name="setHtml" value="设置HTML" />
        <input type="button" name="setText" value="设置文本" />
        <input type="button" name="insertHtml" value="插入HTML" />
        <input type="button" name="appendHtml" value="添加HTML" />
        <input type="button" name="clear" value="清空内容" />
        <input type="reset" name="reset" value="Reset" />
    </p>
</div>

<script charset="utf-8" src="dist/kindeditor.all.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/requirecdn@2.3.6/lib/index.js"></script> -->

<script>
function init(KEditor) {
    KEditor.ready(function(K) {
        var editor = K.create('textarea[name="content"]', {
            // options
            allowFileManager:true,
            uploadJson:'http://www.baiyu.com/upload.php',
            fileManagerJson:'http://www.baiyu.com/manager.php',
        });
        K('input[name=getHtml]').click(function(e) {
            console.log(editor.html());
        });
        K('input[name=isEmpty]').click(function(e) {
            console.log(editor.isEmpty());
        });
        K('input[name=getText]').click(function(e) {
            console.log(editor.text());
        });
        K('input[name=selectedHtml]').click(function(e) {
            console.log(editor.selectedHtml());
        });
        K('input[name=setHtml]').click(function(e) {
            editor.html('<h3>Hello KindEditor</h3>');
        });
        K('input[name=setText]').click(function(e) {
            editor.text('<h3>Hello KindEditor</h3>');
        });
        K('input[name=insertHtml]').click(function(e) {
            editor.insertHtml('<strong>插入HTML</strong>');
        });
        K('input[name=appendHtml]').click(function(e) {
            editor.appendHtml('<strong>添加HTML</strong>');
        });
        K('input[name=clear]').click(function(e) {
            editor.html('');
        });
    });
}
init(KindEditor)

// 使用 require
//require(['dist/kindeditor.js'], init)
</script>
</body>
</html>